﻿using System;
using System.Drawing;
using System.Configuration;

/// <summary>
///Config 的摘要说明
/// </summary>
/// 
namespace QzEbook.Common
{
    public static class Config
    {
        private static readonly string copyRight;
        private static readonly string connectionString;
        private static readonly string providerName;
        private static readonly string userBookSavePath;
        private static readonly Size bookThumbSize;
        private static readonly int pageSize;


        #region 属性说明;

        /// <summary>
        /// 版权网站,主要用于水印;
        /// </summary>
        public static string CopyRight
        {
            get { return Config.copyRight; }
        } 

        /// <summary>
        /// 一个分页数;
        /// </summary>
        public static int PageSize
        {
            get { return Config.pageSize; }
        } 

        /// <summary>
        /// 缩略图大小;
        /// </summary>
        public static Size BookThumbSize
        {
            get { return Config.bookThumbSize; }
        } 
        
        /// <summary>
        /// 用户上传主要保存的位置，属于整体，如一改变，以前的用户上传路径就全部出错;
        /// </summary>
        public static string UserBookSavePath
        {
            get { return Config.userBookSavePath; }
        }

        /// <summary>
        /// 当前数据库引擎；
        /// </summary>
        public static string ProviderName
        {
            get { return Config.providerName; }
        }

        /// <summary>
        /// 连接名称;
        /// </summary>
        public static string ConnectionString
        {
            get { return Config.connectionString; }
        }

        #endregion


        /// <summary>
        /// 存储站点通用数据;
        /// </summary>
        static Config()
        {
            connectionString = ConfigurationManager.ConnectionStrings["qzEbookConnection"].ConnectionString;
            providerName = ConfigurationManager.ConnectionStrings["qzEbookConnection"].ProviderName;
            userBookSavePath = ConfigurationManager.AppSettings["UserBookSavePath"];
            pageSize =int.Parse(ConfigurationManager.AppSettings["PageSize"]);
            copyRight = ConfigurationManager.AppSettings["CopyRight"];

            string[] sizeString = ConfigurationManager.AppSettings["BookThumbSize"].Split(',');
            int width = int.Parse(sizeString[0]);
            int height = int.Parse(sizeString[1]);
            bookThumbSize = new Size(width,height);

        }
    }
}
